# -*- coding:utf8 -*-
import matplotlib
import matplotlib.pyplot as plt
import numpy as np

# 防止报错module 'backend_interagg' has no attribute 'FigureCanvas'
matplotlib.use('TkAgg')


def draw(datas):
    np.random.seed(0)  # 确保每次运行代码时结果相同
    num_curves = 1

    # 生成随机损失曲线
    loss_curves = []
    for i in range(num_curves):
        # noise = np.random.normal(0, 0.1, 1000)
        # curve = np.logspace(-1, -3, 100) + noise
        curve = np.sin(np.linspace(0, 2, 100))
        curve2 = np.cos(np.linspace(0, 4, 120))
        loss_curves.append(curve)
        loss_curves.append(curve2)

    # 绘制多条损失曲线
    plt.figure(figsize=(10, 6))
    for i, curve in enumerate(loss_curves):
        iterations = np.arange(len(curve))
        plt.plot(iterations, curve, label=f'model {i + 1}')

    plt.xlabel('steps')
    plt.ylabel('loss')
    plt.title('loss info')
    plt.legend()
    plt.grid(True)
    plt.show()


def main():
    draw([])


if __name__ == '__main__':
    main()
